package com.ningxun.pagent.web.controller.teenage;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ningxun.pagent.bus.domain.aichat.BaseAIChat;
import com.ningxun.pagent.bus.service.aichat.IBaseAIChatService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ningxun.pagent.common.annotation.Log;
import com.ningxun.pagent.common.core.controller.BaseController;
import com.ningxun.pagent.common.core.domain.AjaxResult;
import com.ningxun.pagent.common.enums.BusinessType;
import com.ningxun.pagent.common.utils.poi.ExcelUtil;
import com.ningxun.pagent.common.core.page.TableDataInfo;

/**
 * 消息Controller
 * 
 * @author pagent
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/bus/AIChat")
public class BaseAIChatController extends BaseController
{
    @Autowired
    private IBaseAIChatService baseAIChatService;

    /**
     * 查询消息列表
     */
    @PreAuthorize("@ss.hasPermi('bus:AIChat:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseAIChat baseAIChat)
    {
        startPage();
        List<BaseAIChat> list = baseAIChatService.selectBaseAIChatList(baseAIChat);
        return getDataTable(list);
    }

    /**
     * 导出消息列表
     */
    @PreAuthorize("@ss.hasPermi('bus:AIChat:export')")
    @Log(title = "消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseAIChat baseAIChat)
    {
        List<BaseAIChat> list = baseAIChatService.selectBaseAIChatList(baseAIChat);
        ExcelUtil<BaseAIChat> util = new ExcelUtil<BaseAIChat>(BaseAIChat.class);
        util.exportExcel(response, list, "消息数据");
    }

    /**
     * 获取消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:AIChat:query')")
    @GetMapping(value = "/{messageId}")
    public AjaxResult getInfo(@PathVariable("messageId") Long messageId)
    {
        return success(baseAIChatService.selectBaseAIChatByMessageId(messageId));
    }

    /**
     * 新增消息
     */
    @PreAuthorize("@ss.hasPermi('bus:AIChat:add')")
    @Log(title = "消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseAIChat baseAIChat)
    {
        return toAjax(baseAIChatService.insertBaseAIChat(baseAIChat));
    }

    /**
     * 修改消息
     */
    @PreAuthorize("@ss.hasPermi('bus:AIChat:edit')")
    @Log(title = "消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseAIChat baseAIChat)
    {
        return toAjax(baseAIChatService.updateBaseAIChat(baseAIChat));
    }

    /**
     * 删除消息
     */
    @PreAuthorize("@ss.hasPermi('bus:AIChat:remove')")
    @Log(title = "消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{messageIds}")
    public AjaxResult remove(@PathVariable Long[] messageIds)
    {
        return toAjax(baseAIChatService.deleteBaseAIChatByMessageIds(messageIds));
    }
}
